home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Demos / DE_MesaAR1 / Examples / AddIn / Inc.m < prev    next >
Text File  |  1992-05-25  |  2KB  |  47 lines

  1. /**************************************************************************
  2.  *                                                                        *
  3.  *                                                                        *
  4.  *          This code is copyright (c) 1992                               *
  5.  *                     Athena Design, Inc.                                *
  6.  *                     and David Pollak                                   *
  7.  *                                                                        *
  8.  *                ALL RIGHTS RESERVED                                     *
  9.  *                                                                        *
  10.  *                                                                        *
  11.  *                                                                        *
  12.  *                                                                        *
  13.  *                                                                        *
  14.  **************************************************************************/
  15.  
  16. #import "Inc.h"
  17. #import <libc.h>
  18.  
  19. @implementation IncAddIn
  20.  
  21. + (char *)name
  22. {
  23.     return "INC";
  24.     }
  25.     
  26. - execute:(void *)stack numberOfParams:(int)num sheet:(void *)sh
  27. {
  28.     AddInValue aiv;
  29.     double n = 0;
  30.     int error = noError;
  31.     
  32.     initAddInValue(&aiv);
  33.     
  34.     if (num != 1) pushErrorOnStack(stack,badFormulaError);
  35.     else {
  36.         popValueFromStack(stack,&aiv);
  37.         n = getAddInValueNumber(&aiv,&error);
  38.         if (error != noError) pushErrorOnStack(stack,error);
  39.         else pushNumberOnStack(stack,n + 1);
  40.         }
  41.     
  42.     freeAddInValue(&aiv);
  43.     return self;
  44.     }
  45.  
  46. @end
  47.